package com.changgou.business.lister;

import org.springframework.amqp.rabbit.annotation.RabbitListener;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class AdListener {

    @Autowired
    private RestTemplate restTemplate;

    @RabbitListener(queues = "ad_update_queue_before")
    public void receiveMessage(String message) {
        System.out.println("接收到的消息为:" + message);
        //发起远程调用
        String url = "http://192.168.200.128/ad_update?position=" + message;
        restTemplate.getForObject(url, String.class);
    }

    @RabbitListener(queues = "ad_update_queue_after")
    public void receiveMessage1(String message) {
        System.out.println("接收到的消息为:" + message);
        //发起远程调用
        String url = "http://192.168.200.128/ad_update?position=" + message;
        restTemplate.getForObject(url, String.class);
    }
}